<!DOCTYPE HTML>
<html>
<head>
    <title>Login</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <link href='http//fonts.googleapis.com/css?family=Exo+2' rel='stylesheet' type='text/css'>
    <script type="text/javascript" src="js/jquery1.min.js"></script>
    <!-- start menu -->
    <link href="css/megamenu.css" rel="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="js/megamenu.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <script>$(document).ready(function () {
        $(".megamenu").megamenu();
        // 添加头
        $(".header").load("head.html");

    });</script>
    <!-- dropdown -->
    <script src="js/jquery.easydropdown.js"></script>
</head>
<body>
<div class="header"></div>

<div class="login">
    <div class="wrap">
        <!--<div class="col_1_of_login span_1_of_login">
            <img src="images/a-img.jpg">
            <div class="clear"></div>
        </div>-->
        <div class="col_1_of_login span_1_of_login">
            <div class="login-title">
                <h4 class="title">闲书上传</h4>
                <div id="loginbox" class="loginbox">
                    <!--<form method="post" name="login" id="login-form">-->
                    <fieldset class="input">
                        <p id="upload-form-username">
                            <label for="modlgn_name">书名</label>
                            <input id="modlgn_name" type="text" name="name" class="inputbox" size="18"
                                   autocomplete="off">
                        </p><br>
                        <p id="upload-form-image">
                        <p>图片上传</p>
                        <input id="modlgn_image" type="file" name="image" size="18"
                               autocomplete="off"></br>
                        </p><br>
                        <p id="upload-form-basc">
                            <label for="modlgn_basc">描述</label>
                            <input id="modlgn_basc" type="text" name="besc" class="inputbox" size="400"
                                   autocomplete="off"></br>
                        </p><br>
                        <p id="upload-form-leibie">
                        <p>图书类别</p>
                        <select id="modlgn_cid">
                            <option value="1" name="cid">儿童</option>
                            <option value="2" name="cid">教育</option>
                            <option value="3" name="cid">生活</option>
                            <option value="4" name="cid">科技</option>
                            <option value="5" name="cid">小说</option>
                            <option value="6" name="cid">励志</option>
                        </select></br>
                        </p>
                        <span id="errorText" hidden="hidden" style="color: red"></span>
                        <div class="remember">
                            <!--<input type="submit" name="Submit" onclick="login()" class="button" value="登录">-->
                            <button onclick="addBook()" style="display:block;margin:0 auto"> 上传</button>


                            <div class="clear"></div>
                        </div>
                    </fieldset>
                    <!--</form>-->
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script type="text/javascript">
    function addBook() {
        $.ajax({
            url: "book/addBook.do",
            type: "POST",
            data: {
                name: $("#modlgn_name").val(),
                image: $("#modlgn_image").val(),
                besc: $("#modlgn_besc").val(),
                cid: $("#modlgn_cid").val(),
            },
            dataType: "json",
            cache: false,
            success: function (data) {
                if (data.success) {
                    alert("上传成功");
                    /*存入bookCase数据*/
                    var uid = null;
                    /*获得session中的对象*/
                    $.ajax({
                        url: "user/getUser.do",
                        type: "POST",
                        data: {},
                        dataType: "json",
                        cache: false,
                        success: function (dataee) {
                            if (dataee != null && (uid = dataee.id) != null) {
                                $.ajax({
                                    url: "case/addBookToCase.do",
                                    type: "POST",
                                    data: {
                                        lid: uid,
                                        bookId: data.data.id
                                    },
                                    dataType: "json",
                                    cache: false,
                                    success: function (data) {
                                    }
                                });
                                window.location.href = "checkout.html";
                            }
                        }
                    });
                } else {
                    $("#errorText").html(data.message);
                    $("#errorText").show();
                }
            }
        });

    }


</script>
<div class="footer">
    <div class="footer-bottom">
        <div class="wrap">
            <div class="copy">
                <p>Copyright &copy; 2014.Company name All rights reserved.<a target="_blank"
                                                                             href="http//www.zjf88.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a>
                </p>
            </div>
            <div class="f-list2">
                <ul>
                    <li class="active"><a href="about.html">关于我们</a></li>
                    |
                    <li><a href="delivery.html">服务条款</a></li>
                    |
                    <li><a href="contact.html">联系我们</a></li>
                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div style="display:none">
    <!--<script src='http//v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script>-->
</div>
</body>

</html>